High-contrast imaging from space must overcome two major noise sources to successfully detect a terrestrial planet angularly close to its parent star: photon noise from diffracted star light, and speckle noise from star light scattered by instrumentally-generated wavefront perturbation. Coronagraphs tackle only the photon noise contribution by reducing diffracted star light at the location of a planet. Speckle noise should be addressed with adaptative-optics systems. Following the tracks of Malbet, Yu and Shao (1995), we develop in this paper two analytical methods for wavefront sensing and control that aims at creating dark holes, i.e. areas of the image plane cleared out of speckles, assuming an ideal coronagraph and small aberrations. The first method, speckle field nulling, is a fast FFT-based algorithm that requires the deformable-mirror influence functions to have identical shapes. The second method, speckle energy minimization, is more general and provides the optimal deformable mirror shape via matrix inversion. With a NxN deformable mirror, the size of matrix to be inverted is either N^2xN^2 in the general case, or only NxN if influence functions can be written as the tensor product of two one-dimensional functions. Moreover, speckle energy minimization makes it possible to trade off some of the dark hole area against an improved contrast. For both methods, complex wavefront aberrations (amplitude and phase) are measured using just three images taken with the science camera (no dedicated wavefront sensing channel is used), therefore there are no non-common path errors. We assess the theoretical performance of both methods with numerical simulations, and find that these speckle nulling techniques should be able to improve the contrast by several orders of magnitude.